package com.quectel.core.module.device.entity.mongo;

import com.quectel.constant.BackupConfigConstants;
import com.quectel.core.constants.MongoCollectionConstants;
import com.quectel.core.module.device.entity.DeviceEntity;
import com.quectel.util.client.mongo.MongoBaseModel;
import lombok.Data;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoId;

import java.util.Date;
import java.util.Map;

/**
 * 数据上报的dto
 *
 * @author caolu
 * @email louis.cao@quectel.com
 */
@Data
@CompoundIndex(name = "idx_device_id", def = "{'deviceEntity._id': 1}", background = true)
@CompoundIndex(name = "idx_tenant_village", def = "{'deviceEntity.tenantId': 1,'deviceEntity.villageId': 1}", background = true)
@Document(MongoCollectionConstants.DEVICE_DATA_LOG)
public class MongoDeviceDataLogModel implements MongoBaseModel {

    @MongoId
    private Long id;

    private String originalData;

    private Map<String, Object> parsedData;

    @Indexed(name = "idx_create_time", background = true, expireAfterSeconds = BackupConfigConstants.MONGO_LOG_DATA_DEFAULT_RETAIN_SECONDS)
    private Date createTime;


    private DeviceEntity deviceEntity;
}
